// pages/register/register.js
Page({
    data:{
        // id:'',
        username:''
    },
    sumbit(data) {
        var password = data.detail.value.password;
        var checkPassword = data.detail.value.checkPassword;
        var name = data.detail.value.username;
        var phone = data.detail.value.phone;
        var nickname = data.detail.value.nickname;
        console.log(password,checkPassword,name);
        if(password && checkPassword && name && phone && nickname){
            if(password == checkPassword) {
                console.log("success");
                wx.request({
                    url: 'http://localhost:8080/user/register?name='+name+'&nickname='+nickname+'&tel='+phone+'&password='+password,
                    method:'POST',
                    header:{
                        'content-type':'application/json'
                    },
                    success:function(res){
                        console.log(res.data);
                        
                        wx.navigateTo({
                            url: '/pages/login/login?username='+name
                        })
                    }
                })
            }else{
                wx.showModal({
                    title:'提示',
                    content:'再次输入密码与第一次不符！'
                })
            }
        }else{
            wx.showModal({
                title:'提示',
                content:'请填写完整！'
            })
        }
    },

})